package nyist.media.entity.admin;

import lombok.Getter;
import lombok.Setter;
import nyist.media.entity.BaseEntity;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * 系统角色
 *
 * @author dcf
 */
@Getter
@Setter
@Entity
@Table(name = "m_p_role")
public class Role extends BaseEntity {
    
    private static final long serialVersionUID = 5934368983163111695L;

    /**
     * 角色名称	varchar(30)	非空
     */
    @Column(nullable = false, length = 30)
    private String name;

    /**
     * 是否默认	bit(1)	非空
     */
    @Column(nullable = false, columnDefinition = "bit(1)")
    private boolean roleDef;

    /**
     * 角色权限
     */
    @ManyToMany
    @JoinTable(name = "m_role_auths")
    private Set<MenuAuth> auths = new HashSet<>();

    /**
     * 已有管理员
     */
    @ManyToMany(fetch = FetchType.LAZY, mappedBy = "roles")
    private Set<Admin> admins = new HashSet<>();
}
